    
import 'package:flutter/material.dart';
import '../../services/ScreenAdatper.dart';
import './Cart.dart';
import './Category.dart';
import './Home.dart';
import './User.dart';
  
  class Tabs extends StatefulWidget {
    Tabs({Key key}) : super(key: key);
    _TabsState createState() => _TabsState();
  }

  class _TabsState extends State<Tabs> {
    int _currentIndex = 0;
    PageController _pageController = new PageController();
    List<Widget> _pageList = [
      HomePage(),
      CategoryPage(),
      CartPage(),
      UserPage(),
    ];
    @override
    Widget build(BuildContext context) {
      ScreenAdatper.init(context);
      return Scaffold(
        // appBar: AppBar(
        //   leading: IconButton(
        //     icon: Icon(Icons.center_focus_weak,size:28,color:Colors.black87),
        //     onPressed: (){

        //     },
        //   ),
        //   title: InkWell(
        //     child: Container(
        //       padding: EdgeInsets.only(left: ScreenAdatper.width(30)),
        //       height:ScreenAdatper.height(68),
        //       decoration: BoxDecoration(
        //         color: Color.fromRGBO(233, 233, 233, 0.8),
        //         borderRadius: BorderRadius.circular(30)
        //       ),
        //       child: Row(
        //         children: <Widget>[
        //           Icon(Icons.search),
        //           Text("笔记本",style: TextStyle(fontSize: ScreenAdatper.size(28)),)
        //         ],
        //       ),
        //     ),
        //     onTap: (){
        //       Navigator.pushNamed(context, '/search');
        //     },
        //   ),
        //   actions: <Widget>[
        //     IconButton(
        //       icon: Icon(Icons.message,size:28,color:Colors.black87),
        //       onPressed: (){},
        //     )
        //   ],
        // ),
        body: PageView( 
          physics: NeverScrollableScrollPhysics(), //禁止页面左右切换  默认是可以滑动的
          onPageChanged:(index){
            setState(() {
              this._currentIndex = index;
            });
          },
          controller: this._pageController,
          children: this._pageList,
        ),
        bottomNavigationBar: BottomNavigationBar(
          fixedColor:Colors.red,
          type: BottomNavigationBarType.fixed,
          onTap: (index){
            setState(() {
               this._currentIndex = index;
               this._pageController.jumpToPage(index); 
            });
          },
          currentIndex: this._currentIndex,
          items: [
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              title: Text('首页')
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.category),
              title: Text('分类')
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.shopping_cart),
              title: Text('购物车')
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.people),
              title: Text('我的')
            )
          ],
        ),
      );
    }
  }